package tools;

import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.Camera;
import android.util.Log;


/**
 *
 *
 *
 * @author jianjunhuang.me@foxmail.com
 * @since 2017/1/11
 *
 * 获取 Camera 实例
 * 检查是否有摄像头
 *
 */
public class CameraInterface {

    /**
     * 检查是否有摄像头
     *
     * @param context
     * @return
     */
    public boolean checkCameraHardware(Context context) {
        if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
            return true;
        } else {
            return false;
        }
    }

    /**
     *
     * 获取 Camera 实例
     *
     * @return Camera Instance
     */
    public static Camera getCameraInstanc(){
        Camera mCamera = null;
        try{
            mCamera = Camera.open();
        }catch(Exception e){
            Log.e("tag","Camera is not available");
        }
        return mCamera;
    }


}
